package com.itheima.jdk8date;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;

/**
 * Period
 */
public class Test06 {

    public static void main(String[] args) {
        Period teTime = Period.between(LocalDate.of(2016, 8, 10), LocalDate.of(2020, 12, 31));


        System.out.println(teTime);

        System.out.println(teTime.getYears());
        System.out.println(teTime.getMonths());
        System.out.println(teTime.getDays());
        System.out.println(teTime.toTotalMonths());


        Duration baiTime = Duration.between(LocalDateTime.of(2020, 12, 31, 0, 0, 0),
                LocalDateTime.of(2022, 5, 10, 15, 20, 30));
        System.out.println(baiTime);
        System.out.println(baiTime.toSeconds());
        System.out.println(baiTime.toMillis());
        System.out.println(baiTime.toNanos());
        System.out.println(baiTime.toDays());

    }
}
